﻿<Window x:Class="Dispatcher.Views.EventEditControl"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:Converters="clr-namespace:Dispatcher.Converters"
        xmlns:Repository="clr-namespace:Repository;assembly=Repository"
        Title="Событие" Height="408" Width="366">
    <Window.Resources>

      <Converters:PersonShortNameConverter x:Key="PersonShortNameConverter"/>
      <Converters:PersonFullNameConverter x:Key="PersonFullNameConverter"/>
      <Converters:VisibilityTrueConverter x:Key="VisibilityTrueConverter"/>
      <Converters:VisibilityFalseConverter x:Key="VisibilityFalseConverter"/>
      
        <DataTemplate DataType = "{x:Type Repository:Person}">
            <Grid AllowDrop="True">
                <StackPanel Orientation="Horizontal">
                    <TextBlock 
                        Text="{Binding Converter={StaticResource PersonShortNameConverter}}"
                        ToolTip="{Binding Converter={StaticResource PersonFullNameConverter}}"/>
                </StackPanel>
            </Grid>
        </DataTemplate>

        <DataTemplate DataType = "{x:Type Repository:EventGroup}">
            <Grid AllowDrop="True">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Path=Name}"/>
                </StackPanel>
            </Grid>
        </DataTemplate>
        
        <DataTemplate x:Key="ComboBoxItemTemplate">
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding IsChecked}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked">
                    <StackPanel Orientation="Horizontal" Width="200">
                        <TextBlock Text="{Binding Path=Name}" ToolTip="{Binding Path=Description}"  Width="Auto"/>
                    </StackPanel>
                </CheckBox>
            </StackPanel>
        </DataTemplate>
        
    </Window.Resources>
    
    <Grid Width="314">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>


        <TextBlock Margin="5" Grid.Row="1" Grid.Column="0" Text="Описание"/>
        <TextBlock Margin="5" Grid.Row="2" Grid.Column="0" Text="Время начала"/>
        <TextBlock Margin="5" Grid.Row="3" Grid.Column="0" Text="Время окончания"/>
        <TextBlock Margin="5" Grid.Row="4" Grid.Column="0" Text="Тип события"/>
        <TextBlock Margin="6" Grid.Row="5" Grid.Column="0" Text="Организатор" Name="Organazer"/>
        <TextBlock Margin="6" Grid.Row="6" Grid.Column="0" Text="Участники" Visibility="Collapsed"/>



        <TextBox Grid.Column="1" Grid.Row="1" Margin="5" Text="{Binding Name, Mode=TwoWay}" AcceptsReturn="True"/>
        <TextBox Grid.Column="1" Grid.Row="2" Margin="5" Text="{Binding StartTime, Mode=TwoWay}"/>
        <TextBox Grid.Column="1" Grid.Row="3" Margin="5" Text="{Binding EndTime, Mode=TwoWay}"/>
        <ComboBox Grid.Column="1" Grid.Row="4" Margin="5" Name="Combo1" ItemsSource="{Binding Path=ClassTypes}" SelectedItem="{Binding SelectedClassType, Mode=TwoWay}" SelectedIndex="0" IsReadOnly="True"/>
        <ComboBox Grid.Column="1" Grid.Row="5" Margin="5" Name="Combo2" ItemsSource="{Binding Path=OrganizePersons}" SelectedItem="{Binding SelectedOrganizePerson, Mode=TwoWay}" IsReadOnly="True"/>
        <ComboBox Visibility="Collapsed" Grid.Column="1" Grid.Row="6" Margin="5" ItemTemplate="{StaticResource ComboBoxItemTemplate}" Name="Combo3" ItemsSource="{Binding Path=ModelContainer.EquipmentTypeSet}" IsEditable="True" IsReadOnly="True" Text="Выберите участников..."/>
      <GroupBox Name="PeriodGroup" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="7" Visibility="{Binding IsSingle, Converter={StaticResource VisibilityFalseConverter}}">
        <Grid>
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
          </Grid.RowDefinitions>

          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
          </Grid.ColumnDefinitions>
          <TextBlock Margin="6" Grid.Row="7" Grid.Column="0" Text="Переодичность"/>
          <TextBlock Margin="6" Grid.Row="8" Grid.Column="0" Text="Начало периода"/>
          <TextBlock Margin="6" Grid.Row="9" Grid.Column="0" Text="Конец периода"/>
        <ComboBox Grid.Column="1" Grid.Row="7" Margin="5" ItemTemplate="{StaticResource ComboBoxItemTemplate}" Name="Combo4" ItemsSource="{Binding Path=Weeks}" IsEditable="True" IsReadOnly="True" Text="Выберите недели..."/>
        <DatePicker Grid.Column="1" Grid.Row="8" Margin="5" SelectedDate="{Binding PeriodStart, Mode=TwoWay}"/>
        <DatePicker Grid.Column="1" Grid.Row="9" Margin="5" SelectedDate="{Binding PeriodEnd, Mode=TwoWay}"/>
        </Grid>
       </GroupBox>

      <GroupBox Name="SingleGroup" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="8" Visibility="{Binding IsSingle, Converter={StaticResource VisibilityTrueConverter}}">
        <Grid>
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
          </Grid.RowDefinitions>

          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
          </Grid.ColumnDefinitions>

          <TextBlock Margin="6" Grid.Row="9" Grid.Column="0" Text="Дата проведения"/>
         
          <DatePicker Grid.Column="1" Grid.Row="9" Margin="1,5,5,5" SelectedDate="{Binding SingleDate, Mode=TwoWay}" Grid.ColumnSpan="3" Width="131" />
        </Grid>
      </GroupBox>
      
      <CheckBox Grid.Column="1" Grid.Row="9" IsChecked="{Binding IsSingle, Mode=TwoWay}">Разовое</CheckBox>
      <StackPanel Margin="5" Grid.Column="1" Grid.Row="10" Orientation="Horizontal">
            <Button Margin="10" Width="77" Click="OkButton_Click">Ok</Button>
            <Button Margin="10" Width="77" Click="CancedlButton_Click">Cancel</Button>
        </StackPanel>
        
    </Grid>
</Window>
